package com.example.mylock;

import java.util.concurrent.locks.Lock;

/**
 * description: ReentryDemo <br>
 * date: 2020/7/8 14:15 <br>
 *
 * @author: ZhangYixin <br>
 * version: 1.0 <br>
 */
public class ReentryDemo {

    public Lock lock = new MyLock();

    public void methodA(){
        lock.lock();
        System.out.println("进入A方法");
        methodB();
        lock.unlock();
    }

    public void methodB(){
        lock.lock();
        System.out.println("进入B方法");
        lock.unlock();
    }

    public static void main(String[] args) {
        ReentryDemo demo = new ReentryDemo();
        demo.methodA();
    }
}
